<template>
  <div>
    <div class="nav-bar" :class="{ is_Fixed: isFixed }">
      <div class="container">
        <div class="pro-title">{{ title }}</div>
        <div class="pro-param">
          <a href="javascript:;">概述</a><span>|</span>
          <a href="javascript:;">参数</a><span>|</span>
          <a href="javascript:;">用户评价</a>
          <slot name="buyNow"></slot>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: "product-param",
  props: {
    title: String,
  },
  data() {
    return {
      isFixed: false,
    };
  },
  mounted() {
    window.addEventListener("scroll", this.innerHeight);
  },
  destroyed() {
    window.addEventListener("scroll", this.innerHeight);
  },
  methods: {
    innerHeight() {
      // 获取屏幕高度
      let scrollTop =
        window.pageYOffset ||
        document.documentElement.scrollTop ||
        document.body.scrollTop;
      this.isFixed = scrollTop > 152 ? true : false;
    },
  },
  destroyed() {
    window.removeEventListener("scroll", this.innerHeight);
  },
};
</script>

<style lang="scss">
@import "@/assets/scss/base.scss";
@import "@/assets/scss/mixin.scss";
@import "@/assets/scss/config.scss";
.nav-bar {
  height: 70px;
  line-height: 70px;
  // border: 1px solid $colorH;
  background-color: #ffffff;
  z-index: 10;
  &.is_Fixed {
    position: fixed;
    top: 0;
    width: 100%;
    box-shadow: 0 5px 5px $colorE;
  }
  .container {
    @include flex();
    .pro-title {
      font-size: $fontH;
      color: $colorB;
      font-weight: bold;
    }
    .pro-param {
      font-size: $fontJ;
      span {
        margin: 0 10px;
      }
      a {
        color: $colorC;
      }
    }
  }
}
</style>